package com.example.saas.controller;

import com.example.saas.domain.DataSource;
import com.example.saas.service.DataSourceServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 数据源控制层
 */
@RestController
@RequestMapping("/ds")
public class DataSourceController {

    @Resource
    private DataSourceServiceImpl dataSourceService;

    @PostMapping("/list")
    private ResponseEntity<List<DataSource>> list(){
        List<DataSource> list = dataSourceService.getDataSourceList();
        return ResponseEntity.ok(list);
    }

    @PostMapping("/add")
    private ResponseEntity<Object> add(DataSource dataSourceDTO){
        dataSourceService.addDataSource(dataSourceDTO);
        return ResponseEntity.ok("");
    }

    @PostMapping("/delete")
    private ResponseEntity<Object> delete(String key){
        dataSourceService.del(key);
        return ResponseEntity.ok("");
    }

}
